package com.wbsxch.demo04.refactoring;

public class Movie {

    public static final int REGULAR = 0;//普通片
    public static final int NEW_RELEASE = 1;//新片
    public static final int CHILDRENS = 2;//儿童片

    private String _title;

    private int _priceCode;

    public Movie(String _title, int _priceCode) {
        this._title = _title;
        this._priceCode = _priceCode;
    }

    public String getTitle() {
        return _title;
    }

    public int getPriceCode() {
        return _priceCode;
    }

    public void setPriceCode(int _priceCode) {
        this._priceCode = _priceCode;
    }

    // statement

    public double getAmount(int daysRented){
        double result = 0;
        switch (getPriceCode()){
            case REGULAR:
                result += 2;
                if(daysRented > 2){
                    result += (daysRented - 2) * 1.5;
                }
                break;

            case NEW_RELEASE:
                result += daysRented * 3;
                break;

            case Movie.CHILDRENS:
                result += 1.5;
                if(daysRented > 3){
                    result += (daysRented -3 ) * 1.5;
                }
                break;
        }
        return result;
    }

    public int getFrequentRenterPoints(int daysRented){
        if(getPriceCode() == NEW_RELEASE && daysRented > 1){
            return 2;
        }else {
            return 1;
        }
    }
}
